﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed
#pragma once

#include "GcmpGUiBaseInterface.h"
#include "GbmpTypeDefs.h"
#include "WeakReferenceable.h"

namespace gcmp
{
    class IProgressBarDefinition;
    class IRadioButtonGroupDefinition;
    class ICheckBoxGroupDefinition;
    class IComboBoxDefinition;
    class IControlDefinition;
    class ICommandButtonDefinition;
    class ILineEditDefinition;
    class ILabelDefinition;
    class ICommandButtonMenuDefinition;

    #define IS_DEFINITION "IsDefinition"

    /// \brief 控件接口
    class GCMP_GUI_BASE_INTERFACE_EXPORT IControl : public WeakReferenceable
    {
    public:
        /// \brief 析构函数
        virtual ~IControl();

         /// \brief 得到控件的数据定义
        /// \return  控件数据定义对象
        virtual IControlDefinition* GetControlDefinition() const = 0;

        /// \brief 更新控件状态
        ///
        /// 会根据其控件的定义返回的可见性及可用性更新控件状态；
        /// \return 
        virtual void UpdateStatus() = 0;

        /// \brief 创建button控件
        ///
        /// \param opDefinition  CommandButton控件的数据定义
        /// \return 创建出IControl对象。失败时返回空
        static OwnerPtr<IControl> CreateButton(OwnerPtr<ICommandButtonDefinition> opDefinition);

        /// \brief 创建LineEdit控件
        ///
        /// \param opDefinition  LineEdit控件的数据定义
        /// \return 创建出IControl对象。失败时返回空
        static OwnerPtr<IControl> CreateLineEdit(OwnerPtr<ILineEditDefinition> opDefinition);

        /// \brief 创建Label控件
        ///
        /// \param opDefinition  Label控件的数据定义
        /// \return 创建出IControl对象。失败时返回空
        static OwnerPtr<IControl> CreateLabel(OwnerPtr<ILabelDefinition> opDefinition);

        /// \brief 创建CommandButtonMenu控件
        ///
        /// \param opDefinition  CommandButtonMenu控件的数据定义
        /// \return 创建出IControl对象。失败时返回空
        static OwnerPtr<IControl> CreateCommandButtonMenu(OwnerPtr<ICommandButtonMenuDefinition> opDefinition);

        /// \brief 创建ComboBox控件
        ///
        /// \param opDefinition  ComboBox控件的数据定义
        /// \return 创建出IControl对象。失败时返回空
        static OwnerPtr<IControl> CreateComboBox(OwnerPtr<IComboBoxDefinition> pControlDefinition);

        /// \brief 创建ProgressBar控件
        ///
        /// \param opDefinition  ProgressBar控件的数据定义
        /// \return 创建出IControl对象。失败时返回空
        static OwnerPtr<IControl> CreateProgressBar(OwnerPtr<IProgressBarDefinition> pControlDefinition);

        /// \brief 创建RadioButtonGroup控件
        ///
        /// \param opDefinition  RadioButtonGroup控件的数据定义
        /// \param parentWinId  RadioButtonGroup控件的父窗口ID
        /// \return 创建出IControl对象。失败时返回空
        static OwnerPtr<IControl> CreateRadioButtonGroup(OwnerPtr<IRadioButtonGroupDefinition> pControlDefinition, UInt64 parentWinId);

        /// \brief 创建CheckBoxGroup控件
        ///
        /// \param opDefinition  CheckBoxGroup控件的数据定义
        /// \param parentWinId  CheckBoxGroup控件的父窗口ID
        /// \return 创建出IControl对象。失败时返回空
        static OwnerPtr<IControl> CreateCheckBoxGroup(OwnerPtr<ICheckBoxGroupDefinition> pControlDefinition, UInt64 parentWinId);              
    };
}

